<?php
	include_once 'isLogin.php';
	$table='user_work_experience';			//会员工作经历表
	$userc=new user();
	$user_id=$_GET['id'];		//会员id
	$eid=$_GET['eid'];			//教育经历id

	//教育经历删除
	if($_GET['action']=='del'){
		$res=$commonc->del($table,$eid.',');
	}

	//批量删除
	if($_GET['action']=='delMany'){
		$id=$_POST['id'];
		$res=$commonc->del($table,$id);
		echo $res;
		exit();
	}

	//教育经历添加
	if($_GET['action']=='add'){
		$experience=$_POST['experience'];
		$position=$_POST['position'];
		$limit=$_POST['limit'];
		
		$arr=array('user_id'=>$user_id,'experience'=>$experience,'position'=>$position,'limit'=>$limit,'create_time'=>time());
		$res=$commonc->insert($table,$arr);
		$id=$commonc->insert_id();
		$html='';
		if($res>0){
			$html.='<tr><td> <input type="checkbox" name="checkbox" value="'.$id.'" /></td><td >'.$experience.'</td> <td>'.$position.'</td><td>'.$limit.'</td>		
     	 	<td class="xiugai"><a href="user_work.php?id='.$user_id.'&action=del&eid='.$id.'">删除</a></td></tr>';	
		}
		$result=array('error'=>$res,'html'=>$html);
		echo json_encode($result);
		exit();
	}


	//会员教育经历信息					
	$where=' and ue.user_id="'.$user_id.'" order by ue.id desc';
	$key='*';
	$works=$userc->workList($where,$key);
	$smarty->assign('works',$works['result']);

	
	$smarty->display("user_work.html");
?>